<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> UDT Reference</title>
<link rel="stylesheet" href="udtdoc.css" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>

<body>
<div class="ref_head">&nbsp;UDT Reference: Functions</div>

<h4 class="func_name"><strong>select</strong>Ex</h4>
<p>The <b>selectEx</b> method queries a group of of UDT sockets for IO status.</p>
<p><span class="style1">Note: selectEx is deprecated. Please use <a href="epoll.htm"><strong>epoll</strong></a> instead, which is far more efficienct. </span></p>
<div class="code">int selectEx(<br />
&nbsp; std::vector&lt;UDTSOCKET&gt; <font color="#FFFFFF">fds</font>,<br />
&nbsp; std::vector&lt;UDTSOCKET&gt;* <font color="#FFFFFF">readfds</font>,<br />
&nbsp; std::vector&lt;UDTSOCKET&gt;* <font color="#FFFFFF">writefds</font>,<br />
&nbsp; std::vector&lt;UDTSOCKET&gt;* <font color="#FFFFFF">exceptfds</font>,<br />
&nbsp; const int64_t  <font color="#FFFFFF">msTimeOut</font><br />
);</div>

<h5>Parameters</h5>
<dl>
  <dt><em>fds</em></dt>
  <dd>[in] the group of UDT socket descriptors to be queried, in a C++ vector.</dd>
  <dt><em>readfds</em></dt>
  <dd>[out] Optional pointer to a set of sockets that are ready for recv.</dd>
  <dt><em>writefds</em></dt>
  <dd>[out] Optional pointer to a set of sockets that are ready for send.</dd>
  <dt><em>exceptfds</em></dt>
  <dd>[out] Optional pointer to a set of sockets that are closed or with a broken connection.</dd>
  <dt><em>msTimeOut</em></dt>
  <dd>[in] The time that this function should wait for the status change in the input groups, in milliseconds.</dd>
</dl>

<h5>Return Value</h5>
<p>If any of the read, write, or except group is not empty, <strong>selectEx</strong> returns the number of UDT sockets that are read for read/write or are broken/closed. If no socket is ready before timeout, zero is 
returned. If there is any error, UDT::ERROR is returned and the specific error information can be retrieved using <a href="error.htm">getlasterror</a>. The <i>readfds,writefds</i> and/or 
<em>exceptfds</em> will be updated to contain the ready sockets.</p>


<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC">
  <tr>
    <td width="17%" class="table_headline"><strong>Error Name</strong></td>
    <td width="17%" class="table_headline"><strong>Error Code</strong></td>
    <td width="83%" class="table_headline"><strong>Comment</strong></td>
  </tr>
  <tr>
    <td>EINVPARAM</td>
    <td>5003</td>
    <td>All three socket sets are NULL or at least one of the socket is invalid.</td>
  </tr>
</table>

<h5>Description</h5>
<p>This function <strong>selectEx</strong> is an advanced version of <a href="select.htm">select</a>. In contrast to <a href="select.htm">select</a>, <strong>selectEx</strong> does not modify the input parameter <em>fds</em>, so that applications do not need to replicate or initialize it every time the function is called. </p>
<p>The new function only has one group of input socket descriptors. If a particular event check is not necessary, the corresponding output parameter can be set to NULL. For example, if the application does not care about if a socket is ready for send, the parameter <em>writefds</em> can be NULL. </p>
<p>Finally, <strong>selectEx</strong> specifies the absolute amount of time to wait, while  <a href="select.htm">select</a> requires a clock time in the future to wait until.</p>
<p>Overall,  <strong>selectEx</strong> is more convinient and more efficient. </p>
<dl>
  <h5>See Also</h5>
  <p><strong><a href="select.htm">select</a></strong>, <a href="epoll.htm"><strong>epoll</strong> </a></p>
  <dt>&nbsp;</dt>
</dl>

</body>
</html>
